<template>
    <!-- 巡检异常 -->
    <div class="layout-padding">
      <basic-container class="layout-padding-auto layout-padding-view">
        <avue-crud
            v-model='form'
            ref='crud'
            v-model:page='page'
            :data='tableData'
            :permission='permissionList'
            :table-loading='tableLoading'
            :option='tableOption'
            @on-load='getList'
            @search-change='searchChange'
            @refresh-change='refreshChange'
            @size-change='sizeChange'
            @current-change='currentChange'
        >
           <template #menu-left>
            <!-- v-if='permissions.om_omicheckabnormal_export' -->
            <el-button
                
                class="filter-item"
                plain
                type="primary"
                icon="el-icon-download"
                @click="exportExcel">导出
            </el-button>
          </template>
          <template #inspectionDtolist='scope'>
            <div style='margin-bottom: 2px' v-for='(item,index) in scope.row.inspectionDtolist'
                 :key='index'>{{ index + 1 + "." + item?.inspectionId }}</div>
          </template>
          <template #time-search>
              <el-date-picker
                  style='width:94%;margin-top: 2px'
                  v-model="timeValue"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
              />
          </template>
        </avue-crud>
      </basic-container>
    </div>
  </template>
  
  <script>
  import {fetchList} from '/@/api/check/omicheckabnormal'
  import {tableOption} from '/@/const/crud/check/omicheckabnormal'
//   import {mapGetters} from 'vuex'
  
  export default {
    name: 'abnormal',
    data() {
      return {
        form: {},
        timeValue: "",
        searchForm: {},
        tableData: [],
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        tableLoading: false,
        tableOption: tableOption,
      }
    },
    computed: {
    //   ...mapGetters(['permissions']),
      permissionList() {
        return {
        //   getBtn: this.validData(this.permissions.om_omicheckabnormal_get, false),
        }
      }
    },
    methods: {
      getList(page, params) {
        this.tableLoading = true
        fetchList(
            Object.assign(
                {
                  current: page.currentPage,
                  size: page.pageSize
                },
                params,
                this.searchForm
            )
        )
            .then((response) => {
              this.tableData = response.data.records
              this.page.total = response.data.total
              this.tableLoading = false
            })
            .catch(() => {
              this.tableLoading = false
            })
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize
      },
      currentChange(current) {
        this.page.currentPage = current
      },
      searchChange(form, done) {
        if (this.timeValue) {
          form.startTime = this.timeValue[0] + ''
          form.endTime = this.timeValue[1] + ''
        }
        this.searchForm = form
        this.page.currentPage = 1
        this.getList(this.page, form)
        done()
      },
      refreshChange() {
        this.getList(this.page)
      },
      exportExcel() {
        // this.downBlobFile('/om/omregionalItems/export', this.searchForm, '异常结果.xlsx')
      }
    }
  }
  </script>
  
  <style lang='scss' scoped>
  </style>